package com.copa.l2351;

import java.util.HashSet;
import java.util.Set;

/**
 * @author copa
 * @createDate 2023-01-01 13:37
 * @function set集合方法
 */
public class Test1 {

    public char repeatedCharacter(String s) {
        if (s.length() == 2) {
            return s.charAt(0);
        }
        Set<Character> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            if (!set.contains(c)) {
                set.add(c);
                continue;
            }
            return c;
        }
        // 随便返回一个符号，无意义
        return '\n';
    }

    public static void main(String[] args) {
        String s = "abccbaacz";
        System.out.println(new Test1().repeatedCharacter(s));
    }
}
